package com.hzw.saas.api.product.enums;

import java.util.Objects;

/**
 * 货币类型
 *
 * @author zzl
 * @since 01/28/2021
 */
public enum CurrencyType {

    CNY("CNY", "人民币"),
    JPY("JPY", "日元"),
    USD("USD", "美元");
    private final String value;
    private final String text;

    CurrencyType(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String value() {
        return this.value;
    }

    public String text() {
        return this.text;
    }

    public static String text(String value) {
        for (CurrencyType currencyType : CurrencyType.values()) {
            if (Objects.equals(currencyType.value, value)) {
                return currencyType.text;
            }
        }
        return null;
    }

    public static CurrencyType instance(String value) {
        for (CurrencyType currencyType : CurrencyType.values()) {
            if (Objects.equals(currencyType.value, value)) {
                return currencyType;
            }
        }
        return null;
    }
}
